/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ylystudio.pms.ejb.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Kenny Lin
 */
@Entity
@Table(name = "resource")
@NamedQueries({
    @NamedQuery(name = "Resource.findAll", query = "SELECT r FROM Resource r"),
    @NamedQuery(name = "Resource.findByResId", query = "SELECT r FROM Resource r WHERE r.resId = :resId"),
    @NamedQuery(name = "Resource.findByResNumber", query = "SELECT r FROM Resource r WHERE r.resNumber = :resNumber"),
    @NamedQuery(name = "Resource.findByResName", query = "SELECT r FROM Resource r WHERE r.resName = :resName"),
    @NamedQuery(name = "Resource.findByResPrice", query = "SELECT r FROM Resource r WHERE r.resPrice = :resPrice")})
public class Resource implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "res_id")
    private Integer resId;
    @Basic(optional = false)
    @Column(name = "res_number")
    private long resNumber;
    @Basic(optional = false)
    @Column(name = "res_name")
    private String resName;
    @Basic(optional = false)
    @Column(name = "res_price")
    private double resPrice;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "resource", fetch = FetchType.LAZY)
    private List<ProjectResource> projectResourceList;
    @JoinColumn(name = "rc_id", referencedColumnName = "rc_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private ResourceCategory resourceCategory;

    public Resource() {
    }

    public Resource(Integer resId) {
        this.resId = resId;
    }

    public Resource(Integer resId, long resNumber, String resName, double resPrice) {
        this.resId = resId;
        this.resNumber = resNumber;
        this.resName = resName;
        this.resPrice = resPrice;
    }

    public Integer getResId() {
        return resId;
    }

    public void setResId(Integer resId) {
        this.resId = resId;
    }

    public long getResNumber() {
        return resNumber;
    }

    public void setResNumber(long resNumber) {
        this.resNumber = resNumber;
    }

    public String getResName() {
        return resName;
    }

    public void setResName(String resName) {
        this.resName = resName;
    }

    public double getResPrice() {
        return resPrice;
    }

    public void setResPrice(double resPrice) {
        this.resPrice = resPrice;
    }

    public List<ProjectResource> getProjectResourceList() {
        return projectResourceList;
    }

    public void setProjectResourceList(List<ProjectResource> projectResourceList) {
        this.projectResourceList = projectResourceList;
    }

    public ResourceCategory getResourceCategory() {
        return resourceCategory;
    }

    public void setResourceCategory(ResourceCategory resourceCategory) {
        this.resourceCategory = resourceCategory;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (resId != null ? resId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Resource)) {
            return false;
        }
        Resource other = (Resource) object;
        if ((this.resId == null && other.resId != null) || (this.resId != null && !this.resId.equals(other.resId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ylystudio.pms.ejb.entity.Resource[resId=" + resId + "]";
    }

}
